Fix cargo-run rebasings and tests
authorAlex Crichton <alex@alexcrichton.com>
Wed, 27 Aug 2014 15:01:26 +0000 (08:01 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 27 Aug 2014 15:09:35 +0000 (08:09 -0700)
Closes #443

src/cargo/ops/cargo_run.rs
tests/test_cargo_bench.rs
tests/test_cargo_cross_compile.rs
tests/test_cargo_run.rs

index 100918658ca21be9ee15401b3b5b7aeaaeec32af..16fa41b1aafedb8730de37455bc116994d41ee83 100644 (file)
@@ -11,8 +11,9 @@ pub fn run(manifest_path: &Path,
     let mut src = try!(PathSource::for_path(&manifest_path.dir_path()));
     try!(src.update());
     let root = try!(src.get_root_package());
+    let env = options.env;
     let mut bins = root.get_manifest().get_targets().iter().filter(|a| {
-        a.is_bin() && a.get_profile().is_compile()
+        a.is_bin() && a.get_profile().get_env() == env
     });
     let bin = try!(bins.next().require(|| {
         human("a bin target must be available for `cargo run`")
@@ -24,11 +25,15 @@ pub fn run(manifest_path: &Path,
     }
 
     let compile = try!(ops::compile(manifest_path, options));
-    let mut exe = manifest_path.dir_path().join("target");
-    if options.env == "release" {
-        exe = exe.join("release");
-    }
-    let exe = exe.join(bin.get_name());
+    let dst = manifest_path.dir_path().join("target");
+    let dst = match options.target {
+        Some(target) => dst.join(target),
+        None => dst,
+    };
+    let exe = match bin.get_profile().get_dest() {
+        Some(s) => dst.join(s).join(bin.get_name()),
+        None => dst.join(bin.get_name()),
+    };
     let exe = match exe.path_relative_from(&os::getcwd()) {
         Some(path) => path,
         None => exe,
index 8e11ef80371575c23a9d6abe0b65f51aec9f9450..acbd23ab9214c765924672c8a33360da57195dfa 100644 (file)
@@ -658,6 +658,7 @@ test!(bin_there_for_integration {
                             output);
 })
 
+#[cfg(not(windows))] // FIXME(#456)
 test!(bench_dylib {
     let p = project("foo")
         .file("Cargo.toml", r#"
index 2d37a808457c23d3795fdac4581ead4b3c411dad..7e65190d186779f1fb21ab486929563606a52d4e 100644 (file)
@@ -438,31 +438,13 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
 test!(simple_cargo_run {
     if disabled() { return }
 
-    let target = alternate();
-
-    let build = project("builder")
-        .file("Cargo.toml", r#"
-            [project]
-            name = "foo"
-            version = "0.5.0"
-            authors = ["wycats@example.com"]
-        "#)
-        .file("src/main.rs", format!(r#"
-            fn main() {{
-                assert_eq!(std::os::getenv("TARGET").unwrap().as_slice(), "{}");
-            }}
-        "#, target).as_slice());
-    assert_that(build.cargo_process("cargo-run").arg("--target").arg(target),
-                execs().with_status(0));
-
     let p = project("foo")
-        .file("Cargo.toml", format!(r#"
+        .file("Cargo.toml", r#"
             [package]
             name = "foo"
             version = "0.0.0"
             authors = []
-            build = '{}'
-        "#, build.bin("foo").display()))
+        "#)
         .file("src/main.rs", r#"
             use std::os;
             fn main() {
@@ -471,6 +453,6 @@ test!(simple_cargo_run {
         "#);
 
     let target = alternate();
-    assert_that(p.cargo_process("cargo-run").arg("--target").arg(target),
+    assert_that(p.cargo_process("run").arg("--target").arg(target),
                 execs().with_status(0));
 })
index 9b967432ae95f4c1a3c1bdbaab06b943e1577618..61490b865a4b01b77f568a3a8e44b4cc1f3fc9ea 100644 (file)
@@ -144,7 +144,7 @@ test!(release_works {
             fn main() { if !cfg!(ndebug) { fail!() } }
         "#);
 
-    assert_that(p.cargo_process("cargo-run").arg("--release"),
+    assert_that(p.cargo_process("run").arg("--release"),
                 execs().with_status(0).with_stdout(format!("\
 {compiling} foo v0.0.1 ({dir})
 {running} `target{sep}release{sep}foo`